package com.cowin.sys.controller;


import com.cowin.base.result.Result;
import com.cowin.base.result.ResultGenerator;
import com.cowin.base.BaseController;
import com.cowin.sys.model.TeOfmVehiclePlan;
import com.cowin.sys.model.TmVhcVehicleMovement;
import com.cowin.sys.model.vo.DateFormVo;
import com.cowin.sys.model.vo.OutPutVo;
import com.cowin.sys.model.vo.VehicleMovementVo;
import com.cowin.sys.service.TmVhcVehicleMovementService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by  on 2019/10/29.
 *
 * @author CodeGenerator
 */
@Slf4j
@Api(value = "TmVhcVehicleMovementController", description = "车辆跟踪信息控制器", tags = "TmVhcVehicleMovementController", consumes = "application/json")
@RestController
@RequestMapping("/tm/vhc/vehicle/movement")
public class TmVhcVehicleMovementController extends BaseController<TmVhcVehicleMovement> {
    @Resource
    private TmVhcVehicleMovementService tmVhcVehicleMovementService;


    @ApiOperation(value = "日产量报表查询", notes = "日产量报表查询")
    @PostMapping("/day")
    public Result getDayOutput(@RequestBody OutPutVo outPutVo) {
        List list = tmVhcVehicleMovementService.findDayOutput(outPutVo);
        return ResultGenerator.genSuccessResult(list);

    }

    @ApiOperation(value = "月周范围产量报表查询", notes = "月周范围产量报表查询")
    @PostMapping("/scope")
    public Result getScopeOutput(@RequestBody OutPutVo outPutVo) {
        List list = tmVhcVehicleMovementService.findScopeOutput(outPutVo);
        return ResultGenerator.genSuccessResult(list);
    }

    @ApiOperation(value = "计划执行完成报表", notes = "计划执行完成报表")
    @PostMapping("/plan/point/position")
    public Result getPointPositionForm(@RequestBody TeOfmVehiclePlan teOfmVehiclePlan) {
        List<Map<String, Object>> map = tmVhcVehicleMovementService.findPointPositionForm(teOfmVehiclePlan);
        return ResultGenerator.genSuccessResult(map);
    }

    @ApiOperation(value = "SetInOut记录报表", notes = "SetInOut记录报表")
    @PostMapping("/set/in/out")
    public Result getSetInOutForm(@RequestBody TeOfmVehiclePlan teOfmVehiclePlan) {
        return ResultGenerator.genSuccessResult(null);
    }

    @ApiOperation(value = "生产日报 月报 年报", notes = "生产日报 月报 年报")
    @GetMapping("/dateForm/{dateTime}")
    public Result getDateForm(@PathVariable String dateTime) {
       List<DateFormVo> list = tmVhcVehicleMovementService.getDateForm(dateTime);
        return ResultGenerator.genSuccessResult(list);
    }

    @ApiOperation(value = "车辆过点信息查询", notes = "车辆过点信息查询")
    @PostMapping("/info")
    private Result getVehicleMovementInfo(@RequestBody VehicleMovementVo vehicleMovementVo){
        if(vehicleMovementVo.getPage()!=-1&&vehicleMovementVo.getLimit()!=-1){
            PageHelper.startPage(vehicleMovementVo.getPage(), vehicleMovementVo.getLimit());
            List<VehicleMovementVo> list = tmVhcVehicleMovementService.getVehicleMovementInfo(vehicleMovementVo);
            PageInfo<VehicleMovementVo> pageInfo = new PageInfo<>(list);
            return ResultGenerator.genSuccessResult(pageInfo);
        }else{
            List<VehicleMovementVo> list = tmVhcVehicleMovementService.getVehicleMovementInfo(vehicleMovementVo);
            return ResultGenerator.genSuccessResult(list);
        }
    }

}
